package com.uestc.ui;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MainMenu extends Application {

    @Override
    public void start(Stage primaryStage) {
        VBox root = new VBox();
        root.setSpacing(10);

        Button btnLogin = new Button("NetDisk");
        btnLogin.setOnAction(e -> {
            LoginView.showLoginDialog();
        });

        Button btnRegister = new Button("Local");
        btnRegister.setOnAction(e -> {
            showLocalDialog();
        });

        root.getChildren().addAll(btnLogin, btnRegister);
        Scene scene = new Scene(root, 600, 400);
        primaryStage.setTitle("pack_uestc");
        primaryStage.setScene(scene);
        primaryStage.show();
    }


    public static void showLocalDialog() {
        Stage dialog = new Stage();
        dialog.setTitle("Local");
        VBox root = new VBox();
        root.setSpacing(10);

        Button btnLogin = new Button("pack");
        btnLogin.setOnAction(e -> {
            PackView.showPackDialog();
            dialog.close();
        });


        Button btnRegister = new Button("restore");
        btnRegister.setOnAction(e -> {
            RestoreView.showRestoreDialog();
            dialog.close();
        });

        Button verifyButton = new Button("verify");
        verifyButton.setOnAction(e -> {
            verifyView.showVerfyDialog();
            dialog.close();
        });

        Button backButton = new Button("back");
        backButton.setOnAction(e -> {
            dialog.close();
        });

        root.getChildren().addAll(btnLogin, btnRegister, verifyButton, backButton);
        Scene scene = new Scene(root, 300, 200);
        dialog.setScene(scene);
        dialog.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}